#include<fstream>
#include<iostream>
#include<string>
#include"predictor.h"

using namespace std;
PREDICTOR predictor;
int main(void)
{
  int b=0;
  int bpredicts=0;
  branch_record_c br;
  ifstream in("trace_nested_for_loop.txt");
  while(1)
   {
       in>>br.instruction_addr;
    in>>br.is_conditional;
    in>>br.is_taken;
      if(in.eof())
        break;
    bool predicted_taken = predictor.get_prediction(&br);
    b++;
    if(predicted_taken!=br.is_taken)
       bpredicts++;

    predictor.update_predictor(&br, br.is_taken);
   }
   cout<<"Total branches:"<<b<<"\nbranch mispredits:"<<bpredicts<<"\n";
   in.close();

   return 0;
}

